package plg.grupo1.Lexico.guiApp;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class PanelSuperiorGui extends JPanel implements ListSelectionListener {

	private static final long serialVersionUID = 1L;

    private JSplitPane splitPane;
    private JTextArea textAreaIzq;

	private JTextArea textAreaDer;

    public PanelSuperiorGui() {

        //panel donde se muestra el fichero de entrada
        textAreaIzq= new JTextArea();
        textAreaIzq.setDoubleBuffered(true);
        textAreaIzq.setLineWrap(true);

        
        //panel donde se muentran los tokens generados
        textAreaDer = new JTextArea();
        textAreaDer.setDoubleBuffered(true);
        textAreaDer.setEditable(false);
        textAreaDer.setLineWrap(true);

        
        JScrollPane ficheroEntradaScrollPane = new JScrollPane(textAreaIzq);
        JScrollPane tokensSalidaScrollPane = new JScrollPane(textAreaDer);
                
        //vista reescalable
        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,ficheroEntradaScrollPane,tokensSalidaScrollPane);
        splitPane.setOneTouchExpandable(true);
        splitPane.setDividerLocation(540);

        /*//Provide minimum sizes for the two components in the split pane.
        Dimension minimumSize = new Dimension(500, 50);
        ficheroEntradaScrollPane.setMinimumSize(minimumSize);
        tokensSalidaScrollPane.setMinimumSize(minimumSize);*/

        //Provide a preferred size for the split pane.
        splitPane.setPreferredSize(new Dimension(400,200));

    }

    public JSplitPane getSplitPane() {
        return splitPane;
    }

    public JTextArea getPanelIzquierdo() {
        return textAreaIzq;
    }
  
    public JTextArea getPanelDerecho() {
        return textAreaDer;
    }
    
    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private static void createAndShowGUI() {

        JFrame frame = new JFrame("");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        PanelSuperiorGui splitPaneDemo = new PanelSuperiorGui();
        frame.getContentPane().add(splitPaneDemo.getSplitPane());

        frame.pack();
        frame.setSize(800,400);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run(){
                createAndShowGUI();
            }
        });
    }

	public void valueChanged(ListSelectionEvent arg0){
		// TODO Auto-generated method stub	
	} 
}
